import {AppConfig} from "./AppConfig";

export class Url {
    constructor(url: string, name: string, method: string, key: string) {
        this._url = url;
        this._name = name;
        this._method = method;
        this._key = key;
    }
    get url(): string {
        return this._url;
    }

    set url(value: string) {
        this._url = value;
    }

    get name(): string {
        return this._name;
    }

    set name(value: string) {
        this._name = value;
    }

    get method(): string {
        return this._method;
    }

    set method(value: string) {
        this._method = value;
    }

    get key(): string {
        return this._key;
    }

    set key(value: string) {
        this._key = value;
    }

    private _url: string;
    private _name: string;
    private _method: string;
    private _key: string;
}

export class Urls {
    protocol?: string;
    host?: string;
    port?: string;
    contextPath?: string;
    urls?: Url[];

    public static POST_LOGIN = 'POST_LOGIN';
    public static GET_TOKEN_USER = 'GET_TOKEN_USER';
    public static POST_CREATE_GROUP = 'POST_CREATE_GROUP';
    public static GET_GROUP_SERVER = 'GET_GROUP_SERVER';


    static getUrl(key: string): Url {
        let newVar = AppConfig.URLS.get(key);
        if (!newVar){
            throw new Error('url not found');
        }
        return newVar;
    }
}